using System;
using System.Collections.Generic;

namespace MTG.DTO
{
    public class Card : ICard
    {
        private string cardName;

        private Guid id;

        private CardType cardType;

        private CardRarity cardRarity;

        private IDictionary<string, object> properties;

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object" /> class.
        /// </summary>
        public Card(string cardName, Guid id, CardType cardType, CardRarity cardRarity)
        {
            this.cardName = cardName;
            this.id = id;
            this.cardType = cardType;
            this.cardRarity = cardRarity;
        }


        /// <summary>
        /// Holds a string of the current name of the card
        /// </summary>
        public string CardName
        {
            get { return cardName; }
            set { cardName = value; }
        }

        /// <summary>
        /// Holds an id of the current card (if more than one are in play)
        /// </summary>
        public Guid Id
        {
            get { return id; }
            set { id = value; }
        }

        /// <summary>
        /// An enumeration of the type of card
        /// </summary>
        public CardType CardType
        {
            get { return cardType; }
            set { cardType = value; }
        }

        /// <summary>
        /// An enumeration of the rarity of the card
        /// </summary>
        public CardRarity CardRarity
        {
            get { return cardRarity; }
            set { cardRarity = value; }
        }

        /// <summary>
        /// A bag of properties that can be used to define the card (e.g. description, power, toughness, etc.)
        /// </summary>
        public IDictionary<string, object> Properties
        {
            get { return properties; }
            set { properties = value; }
        }

        /// <summary>
        /// set a property in the property bag describing this card
        /// </summary>
        public void SetProperty(string strProperty, string objProperty)
        {
            if (objProperty == null) return;
            if (properties.Contains(new KeyValuePair<string, object>(strProperty, objProperty)))
                properties[strProperty] = objProperty;
            else
                properties.Add(new KeyValuePair<string, object>(strProperty, objProperty));
        }

        /// <summary>
        /// retrieve an object out of the property bag
        /// </summary>
        public object GetProperty(string strProperty)
        {
            return properties[strProperty];
        }
    }
}